#ifndef __UTILS_H__
#define __UTILS_H__

#include <stdint.h>
#include <string>
#include <vector>

class CUtils
{
public:
	static const char* IP2String(uint32_t ulIP);
	static const char* IP2String2(uint32_t ulIP);
	static long genSeed();
	static std::string ConvertTo62(uint32_t dwValue);
	static uint32_t ConvertFrom62(const std::string& sValue);
	static uint32_t CheckSum32(const uint32_t* pData, uint32_t dwLen);
	static uint32_t Parity(uint32_t dwData);	
	static char* StrRev(char* str);
	static bool XOR(char* sBuff, uint32_t dwBuffLen, const char* sKey, uint32_t dwKeyLen);
	static bool XOR(std::string& str, const char* sKey, uint32_t dwKeyLen);
	static std::string& Replace(std::string& str, const std::string& from, const std::string& to);
	static uint32_t getLocalAddr(const char *dev_name);
	static bool	IsDigits(const char* pSrc);
	static bool	IsXDigits(const char* pSrc);
	static uint32_t GetCurMS();
	static std::string GetCurDay();
	static std::string GetTime2Day(time_t dwTime);
	static std::string GetTime2Date(time_t dwTime);	
	static uint32_t GetDayTime(uint32_t dwTime);
	static void Usleep(int iMs=50);
	static bool IsColon(const char c);
	static bool IsSlash(const char c);
	static bool IsComma(const char c);
	static void Split(const std::string& str, bool (*func)(const char), std::vector<std::string>& vecRet);
	static void Split(const std::string& str, const std::string& delim, std::vector<std::string>& vecRet);
	static int GetAbsPath(const char *pszPath, char *pszBuf, int iBufLen);
	static char* Trim(char* pStr);
	static std::string Trim(const std::string& str);
	static char* toLower(char* pStr);
	static std::string toLower(const std::string& str);
	static const std::string& toLower(std::string& str);
	static std::string toString(int value);
};

#endif
